package com.lxf.education.service.impl;

import com.lxf.education.dao.MessageListMapper;
import com.lxf.education.pojo.MessagePojo;
import com.lxf.education.pojo.ReslutPojo;
import com.lxf.education.service.MessageService;
import com.lxf.education.utils.ResultVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Luoxingfa on 2022/5/22 0022 01:40
 */
@Service
public class MessageServiceImpl implements MessageService {

    @Resource
    MessageListMapper messageListMapper;
    @Override
    public ResultVo findAll() {
        return null;
    }

    @Override
    public ResultVo getMessageByPage(Integer page, Integer limit) {
        // TODO Auto-generated method stub
        try {
            //计算出初始页
            Integer start = (page-1)*limit;
            //查询数据
            List<MessagePojo> messagePojos = messageListMapper.getAllMessage(start,limit);

            //查询总条数
            int count = messageListMapper.finCount();
            ResultVo successVo = ResultVo.getSuccessVo("success",messagePojos);
            //将总条数设置进去
            successVo.setCount(count);
            return successVo;

        }catch (Exception e){
            e.printStackTrace();
            return ResultVo.getFailVo("fails");
        }
    }
}
